JAVA Programming, For Beginners, Quick Start Guide. by Ray Yao

JAVA Programming, For Beginners, Quick Start Guide. by Ray Yao

Author:Ray Yao [Yao, Ray]
Language: eng
Format: azw3
Publisher: Step by Step Tutorial eBook & Book
Published: 2020-08-05T00:00:00+00:00


Chapter 6

Inheritance & Modifiers

Inheritance

A class can be extended by a child-class.

class child-class extends parent-class;

“extends” is used in a child class extends a parent class.

Example 6.1

class Parent_Class{ // parent class

// define a variable here;

// define a method here;

}

class Child_Class extends Parent_Class{ // child class

// define a variable here;

// define a method here;

}

Explanation:

“class Child_Class extends Parent_Class” means that a child class extends a parent class (also called super class).

Child class can access the variable and method in the parent class, but cannot access the private variable and private method in the parent class.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.